﻿using TimeTest;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;


    
    
    /// <summary>
    ///This is a test class for TimeKeeperTest and is intended
    ///to contain all TimeKeeperTest Unit Tests
    ///</summary>
    [TestClass()]
    public class TimeKeeperTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


     
        [TestMethod()]
        public void TimeKeeperConstructorTest()
        {
            int hours = 10; 
            int minutes = 10; 
            TimeKeeper target = new TimeKeeper(hours, minutes);
            Assert.AreEqual(hours, target.Hours);
            Assert.AreEqual(minutes, target.Minutes);

        }

        /// <summary>
        ///A test for ToString
        ///</summary>
        [TestMethod()]
        public void ToStringTest()
        {
            int hours = 10;
            int minutes = 10;
            TimeKeeper target = new TimeKeeper(hours, minutes);
            string expected = string.Format("it is {0} o'clock and {1} minutes", hours, minutes);
            string actual;
            actual = target.ToString();
            Assert.AreEqual(expected, actual);
            
        }

        /// <summary>
        ///A test for op_Addition
        ///</summary>
        [TestMethod()]
        public void op_AdditionTest()
        {
            TimeKeeper keeper = new TimeKeeper(10, 10);
            int minutesToAdd = 70;
            TimeKeeper expected = new TimeKeeper(11,20); 
            TimeKeeper actual;
            actual = (keeper + minutesToAdd);
            Assert.AreEqual(expected, actual);
        }
        /// <summary>
        ///A test for op_Subtraction
        ///</summary>
        [TestMethod()]
        public void op_SubtractionTest()
        {
            TimeKeeper keeper = new TimeKeeper(10, 10);
            int minutesToSubstract = 10;
            TimeKeeper expected = new TimeKeeper(10, 0);
            TimeKeeper actual;
            actual = (keeper - minutesToSubstract);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for op_Decrement
        ///</summary>
        [TestMethod()]
        public void op_DecrementTest()
        {
            TimeKeeper keeper = new TimeKeeper(10, 10);
            TimeKeeper expected = new TimeKeeper(10, 9);
            TimeKeeper actual;
            actual = --(keeper);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for op_Increment
        ///</summary>
        [TestMethod()]
        public void op_IncrementTest()
        {
            TimeKeeper keeper = new TimeKeeper(10, 10);
            TimeKeeper expected = new TimeKeeper(10, 11);
            TimeKeeper actual;
            actual = ++(keeper);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void AreNotEqualTest()
        {
            TimeKeeper keeper1 = new TimeKeeper(10, 10);
            TimeKeeper keeper2 = new TimeKeeper(10, 11);
            Assert.AreNotEqual(keeper1, keeper2);
        }
       

        ///// <summary>
        /////A test for Hours
        /////</summary>
        [TestMethod()]
        public void HoursTest()
        {
            int hours = 0; 
            int minutes = 0; 
            TimeKeeper target = new TimeKeeper(hours, minutes); 
            int expected = 4; 
            int actual;
            target.Hours = -20;
            actual = target.Hours;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for Minutes
        ///</summary>
        [TestMethod()]
        public void SubstractionWithMoreThanAvailableMinutes()
        {
            TimeKeeper keeper = new TimeKeeper(10, 10);
            int minutesToSubstract = 80;
            TimeKeeper expected = new TimeKeeper(8, 50);
            TimeKeeper actual;
            actual = (keeper - minutesToSubstract);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void AdditionTestToMoreThan24Hours()
        {
            TimeKeeper keeper = new TimeKeeper(23, 50);
            int minutesToAdd = 20;
            TimeKeeper expected = new TimeKeeper(0, 10);
            TimeKeeper actual;
            actual = (keeper + minutesToAdd);
            Assert.AreEqual(expected, actual);
        }

    
}
